﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ResourceBlender_Express {
    /// <summary>
    /// Allows a resource summary for an application to be bound using XAML.
    /// </summary>
    public class ApplicationSummary {
        public string DisplayName { get; set; }
        /// <summary>
        /// Gets or sets the bundles the application contains (formatted).
        /// </summary>
        /// <value>The bundles.</value>
        public List<string> Bundles { get; set; }
        public int TotalElements { get; set; }
        /// <summary>
        /// Gets or sets the completion of resources in each language.
        /// </summary>
        /// <value>The completion map.</value>
        public List<LanguageCompletion> CompletionMap { get; set; }

        /// <summary>
        /// Initializes a new <see cref="ApplicationSummary"/> with the specified name.
        /// </summary>
        /// <param name="name">The display name.</param>
        public ApplicationSummary(string name) {
            this.DisplayName = name;
            this.Bundles = new List<string>();
            this.TotalElements = 0;
            this.CompletionMap = new List<LanguageCompletion>();
        }
    }

    /// <summary>
    /// Shows the resource completion of a language in relation to an application
    /// </summary>
    public class LanguageCompletion : IComparable {
        /// <summary>
        /// Gets or sets the English name of the language.
        /// </summary>
        /// <value>The name of the english.</value>
        public string EnglishName { get; set; }
        /// <summary>
        /// Gets or sets the ISO3166 code used as the language flag image.
        /// </summary>
        /// <value>The ISO3166 code for the language which is used as the flag image).</value>
        public string Image { get; set; }
        /// <summary>
        /// Gets or sets the number translations available in this language.
        /// </summary>
        /// <value>The num translations.</value>
        public int NumTranslations { get; set; }
        /// <summary>
        /// Initializes a new <see cref="LanguageCompletion"/>.
        /// </summary>
        /// <param name="englishName">The English name of the language.</param>
        /// <param name="image">The number translations available in this language.</param>
        /// <param name="numTranslations">The number translations available in this language.</param>
        public LanguageCompletion(string englishName, string image, int numTranslations) {
            this.EnglishName = englishName;
            this.Image = image;
            this.NumTranslations = numTranslations;
        }

        /// <summary>
        /// Compares this LanguageCompletion to another object (by English name).
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj) {
            if(obj is LanguageCompletion) {
                return this.EnglishName.CompareTo((obj as LanguageCompletion).EnglishName);
            } else {
                return 1;
            }
        }
    }
}
